package com.yan.design.two.behavior.s10;

import com.yan.design.two.behavior.s10.sufa.Flay;

/**
 * 10. 策略模式
 *      抽象鸭
 * @author shengren.yan
 * @create 2022-08-14
 */
public abstract class Duck {
    // 属性 - 策略接口
    Flay flay;

    public Duck(){

    }
    // 显示什么鸭子
    public abstract void display();

    public void quack(){
        System.out.println("鸭子会叫");
    }

    public void doFly(){
        if (flay!=null){
            flay.fly();
        }
    }

    public void setFlay(Flay flay) {
        this.flay = flay;
    }
}
